<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont icon-xiangzuo1" @tap="backTo()"></view>
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">绑定银行卡</view>
		</view>	
		<view class="bg_box">
			<image class="bg01" src="/static/bg05.png" mode="widthFix"></image>
			<view class="bg_content">
					
				<view class="details_box">
					<view class="details_title">银行卡信息</view>
					<view class="list">
						<view class="name">姓名</view>
						<input type="text" v-model="name" placeholder="请输入姓名" />
					</view>
					<view class="list">
						<view class="name">身份证号</view>
						<input type="text" v-model="idcode" placeholder="请输入身份证号" />
					</view>
					<view class="list">
						<view class="name">银行卡号</view>
						<input type="text" v-model="cardcode" placeholder="请输入银行卡号" />
					</view>
					<view class="list">
						<view class="name">手机号码</view>
						<input type="text" v-model="phone" placeholder="请输入手机号码" />
					</view>
				<!-- 	<view class="list">
						<view class="name">验证码</view>
						<input type="text" v-model="yzm" placeholder="请输入验证码" />
						<button plain="false" class="yzm" @click="getCode" :disabled="disabled">
							{{ countdown }}
							<text v-show="timestatus">秒重获</text>
						</button>
					</view> -->
					
				</view>
				<view class="clear_box04"></view>
				
				<view class="confirm sub" @click="add_bank()">添加</view>
				
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				scrrol:false,
				info:'',
				yzm:'',
				cardcode : '',
				idcode : '',
				
				countdown: '获取验证码',
				disabled: false,
				timestatus: false,
				clear: '',
				phone:'',
				
			}
		},
		onPageScroll: function(Object) {
			if (Object.scrollTop > 28) {
				this.scrrol = true;
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
			}
		},
		onLoad() {

		},
		methods: {
			add_bank(){
				// if(!uni.$u.test.code(this.yzm, 4)){
				// 	this.showMsg('验证码格式错误');
				// 	return;
				// }
				if(this.name == '' || this.cardcode == ''){
					this.showMsg('请输入完整内容');
					return;
				}
				
				if(!uni.$u.test.idCard(this.idcode)){
					this.showMsg('身份证号格式有误');
					return;
				}
				if(!uni.$u.test.mobile(this.phone)){
					this.showMsg('手机号格式有误');
					return;
				}
				uni.$u.throttle(this.real_add_bank, 800)
			},
			real_add_bank(){
				
				uni.showLoading({
					title: '正在上传中...',
					mask: true,
				});
				helper.Timer.start();
				let param = {
					username : this.name,
					phone : this.phone,
					idcode : this.idcode,
					cardcode : this.cardcode,
					yzm : this.yzm
				};
				
				let url = this.site_url + 'api/auth/member/bank_add';
				this.areq(url,param,'POST').then(res=>{
					helper.Timer.stop();
					let left_time = helper.Timer.getLeftTime(3000);
					// console.log(left_time);
					setTimeout(() => {
						uni.hideLoading();
						if (res.code == 1) {
							this.showMsg('新增成功', 2000, true, 'success');
							this.$emit('bank_add');
							setTimeout(() => {
								this.backTo();
							}, 1200)
						} else {
							this.showMsg(res.msg);
						}
								
					}, left_time);
					
				})
				
				
				
			},
			// 获取验证码
			getCode() {
				var that = this;
				if (!that.phone) {
					this.showMsg('手机号不能为空');
					return;
				}
				that.disabled = true; //禁用点击
				that.countdown = 60;
				that.timestatus = true;
				that.clear = setInterval(that.countDown, 1000);
			},
			// 倒计时
			countDown() {
				var that = this;
				if (!that.countdown) {
					that.disabled = false;
					that.timestatus = false;
					that.countdown = '获取验证码';
					clearInterval(that.clear);
				} else {
					--that.countdown;
				}
			},
			setRule(e){
				let that = this;
				let index = e.currentTarget.dataset.index;
				that.flowList[index].tick = !that.flowList[index].tick
			},
			loadData() {
				let that = this;
				
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				this.$r(url);
			},

		},
	

	}
</script>

<style>
	
	.header{
		background-color: transparent !important;
	}
	
	.header .text{
		background-color: transparent !important;
		color: #333 !important;
	}
	
	.scrrolHeader{
		background-color: #FFE6D0 !important;
	}
	
	.bg_box{
		width: 100%;
		position: relative;
	}
	
	.bg_box .bg01{
		width: 100%;
	}
	
	.bg_box .bg_content{
		width: 92%;
		position: absolute;
		left: calc(50% - 46%);
		top: calc(13.5vw + var(--status-bar-height));
		z-index: 98;
	}
	
	.details_box {
		width: 100%;
		margin-top: 4%;
		background-color: #fff;
		padding: 5vw 4%;
		border-radius: 3vw;
	}
	
	.details_boxNo{
		padding: 0vw 4%;
	}
	
	.details_box .details_title {
		font-size: 4.2vw;
		color: #333;
		font-weight: bold;
		margin-bottom: 5vw;
	}
	
	.details_box .input_box{
		width: 100%;
		display: flex;
		align-items: center;
		border-bottom: 2px solid #FC5D20;
		height: 15vw;
	}
	
	.details_box .input_box .m{
		font-size: 4vw;
		color: #333;
		margin-right: 1vw;
		font-weight: bold;
		margin-top: 2vw;
	}
	
	.details_box .input_box input{
		font-size: 7vw;
		color: #333;
		flex: 1;
		font-weight: bold;
	}
	
	.details_box .list {
		width: 100%;
		padding: 5vw 0;
		border-bottom: 1px solid #F3F3F3;
		display: flex;
		align-items: center;
		position: relative;
	}
	
	.details_box .list .name {
		font-size: 4.2vw;
		font-weight: bold;
		color: #333;
		margin-right: 4vw;
	}
	
	.details_box .list .text {
		flex: 1;
		font-size: 3.5vw;
		color: #333;
		margin-right: 1vw;
		font-weight: bold;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}
	
	.details_box .list .text .i{
		width: 5vw;
		margin-right: 1vw;
	}
	
	.details_box .list .text .i image{
		width: 100%;
	}
	
	.details_box .list input {
		flex: 1;
		font-size: 3.5vw;
		color: #333;
		margin-right: 3vw;
		text-align: right;
		font-weight: bold;
	}
	
	.details_box .list .arrow {
		font-size: 3.5vw;
		color: #333;
	}
	
	.details_box .list .yzm {
		font-size: 3.5vw;
		color: #FC5D20;
		font-weight: bold;
		outline: none;
		background-color: transparent !important;
		border-radius: 10vw;
		height: 10vw;
		border: 1px solid #FC5D20;
	}
	
	.standing{
		width: 100%;
	}
	
	.standing image{
		width: 100%;
	}
	
	.standing .text{
		width: 100%;
		font-size: 3.8vw;
		color: #333;
		font-weight: bold;
		margin-top: 3vw;
		text-align: center;
	}
	
	.details_box .standing:nth-child(2){
		margin-top: 5vw;
	}
	
	
	
	
</style>
